package com.origin.opengles_ndk.dialog.type_list.adapter

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import com.origin.opengles_ndk.R
import com.origin.opengles_ndk.bean.TypeBean
import com.origin.opengles_ndk.databinding.ItemTypeBinding
import com.origin.uilibrary.xrecycleview.adapter.BaseRecycleAdapter
import com.origin.uilibrary.xrecycleview.viewholder.BaseViewHolder

class TypeAdapter(list: MutableList<TypeBean>, context: Context) : BaseRecycleAdapter<TypeBean>(list, context) {
    override fun setItemData(holder: BaseViewHolder, item: TypeBean, position: Int) {
        if (holder.binding is ItemTypeBinding) {
            val itemTypeBinding = holder.binding as ItemTypeBinding
            itemTypeBinding.bn.text = item.name
            itemTypeBinding.bn.setOnClickListener {
                Log.e("点击","1")
                mItemClickListener?.onItemClick(position, item,it)
            }
        }
    }

    override fun getViewResource(inflater: LayoutInflater, viewType: Int, parent: ViewGroup): BaseViewHolder {
        val itemTypeBinding = loadDataBinding<ItemTypeBinding>(inflater, parent, R.layout.item_type)
        return BaseViewHolder(itemTypeBinding)
    }
}